package com.tjetc.controller;

import com.tjetc.entity.Result;
import com.tjetc.entity.User;
import com.tjetc.service.IUserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.ZonedDateTime;
import java.util.Objects;

@RestController
public class UserController {

    @Resource
    private IUserService userService;

    @GetMapping("/user/get/{id}")
    public Result getUserById(@PathVariable("id") int id){
        User user = userService.getUserById(id);
        if (Objects.nonNull(user)) {
            return Result.success("查询用户成功-12000", user);
        }else {
            return Result.error("402", "ID= " + id + "不存在");
        }
    }


    public static void main(String[] args) {
        System.out.println(ZonedDateTime.now());
    }
}
